package com.summer.safe.system.service;

import com.summer.safe.system.dao.OfficeDao;
import com.summer.safe.utils.UserUtils;
import com.summer.safe.system.entity.Office;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional(rollbackFor = Exception.class)
public class OfficeService extends TreeService<OfficeDao, Office> {

	public List<Office> findAll(){
		return UserUtils.getOfficeList();
	}


	public List<Office> findList(Boolean isAll){
		if (isAll != null && isAll){
			return UserUtils.getOfficeAllList();
		}else{
			return UserUtils.getOfficeList();
		}
	}

	public List<Office> findListByType(Office office){
		Office userOfiice = UserUtils.getUser().getOffice();
		return dao.findListByType(office);
	}

	public List<Office> findType(Office office){
		Office userOfiice = UserUtils.getUser().getOffice();
		return dao.findType(office);
	}


	
	@Override
    @Transactional(readOnly = false)
	public void save(Office office) {
		super.save(office);
	}


	
	@Override
    @Transactional(readOnly = false)
	public void delete(Office office) {
		super.delete(office);
	}
	public List<Office> getoffice(){

		return  dao.getoffice();
	}
}
